<template>
	<view class="bkg">
		<customNav style="padding-top: 20px;" title1="会员中心" titleColor="#FFFFFF" bgColor="#1E2327" :backIcon="true"
			backIconColor="white"></customNav>
		<view class="uni-padding-wrap uni-common-mt">
			<uni-segmented-control styleType="text" :current="current" :values="items" :style-type="styleType"
				:active-color="activeColor" @clickItem="onClickItem" />
		</view>
		<view class="content">
			<view class="" v-for="(item,index) in dataList">
				<view class="member_card">
					<image :src="item.cover_url" mode="aspectFill" style="width:100%;"></image>
				</view>
				<image class="middle_bkg" src="../../../static/member_middle_bkg.png" mode=""></image>
				<view class="" style="margin-top: -60px;">
					<view class="benefits_bkg">
						<image src="../../../static/member_benefits_bkg.png" mode="scaleToFill" style="width:100%; height:100%;">
						</image>
					</view>
					<view class="benefits_view" style="">
						<view class="benefits_title"> 专属权益</view>
						<view class="benefits_content">
							<view class="benefits_card" v-for="(benefit, index) in item.benefits">
								<view class="benefit_item">
									<image class="benefit_icon" :src="benefit.icon_url" mode=""></image>
									<view class="benefit_text">
										<view class="benefit_title"> {{benefit.name}} </view>
										<view class="benefit_subTitle"> {{benefit.describe}} </view>
									</view>
								</view>
							</view>
						</view> 
					</view>
				</view>
				

								
			</view>

		</view>
	</view>
</template>

<script>
	import customNav from "@/components/custom-nav/custom-nav.vue";

	import {
		getMemberList
	} from '@/api/user.js'
	export default {
		components: {
			customNav,
		},

		data() {
			return {
				activeColor: "#F1C39E",
				// 分段器数据
				current: 0,
				items: [],
				dataList: [],
			}
		},

		onLoad: function() {
			getMemberList()
			.then(res => {
				console.log('==========' + JSON.stringify(res))
				let code = res.code
				if (code == 0) {
					let dataList = res.data
					this.dataList = dataList
					let arr = []
															
					for (let item of dataList) {
						arr.push(item.name)
					}
					this.items = arr
				}
			})
			.catch(e => {
				
			})
		},

		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			},
			styleChange(e) {
				if (this.styleType !== e.detail.value) {
					this.styleType = e.detail.value
				}
			},
			colorChange(e) {
				if (this.styleType !== e.detail.value) {
					console.log(e.detail.value);
					this.activeColor = e.detail.value
				}
			}
		}
	}
</script>

<style>
	.bkg {
		width: 100%;
		height: 100vh;
		background-color: #222629;
		/* overflow: hidden; */
	}

	.uni-padding-wrap {
		padding: 20px 30px;
	}

	.uni-common-mt {
		/* margin-top: 30px; */
	}
	
		.member_card {
			margin: 0px 33px 0px 33px;
			height: 200px;
		}
		
		.middle_bkg {
			margin: -60px 0px 0px 0px;
			width: 100%;
			height: 100px;
			/* opacity: 0.98; */
		}
		
		.benefits_bkg {
			margin: 0px 19px 0px 19px;
			height: 450px;
			/* position: absolute; */
		}
		
		.benefits_view {
			margin: -420px 19px 0px 19px;
			height: 380px;
			/* background-color: yellow; */
		}
		
		.benefits_title {
			font-size: 16px;
			font-family: Alimama ShuHeiTi;
			font-weight: bold;
			color: #E2E9FB;
			opacity: 1;
			margin-top: 30px;
			display: flex;
			justify-content: center;
		}
		
		.benefits_content {
			margin-top: 30px;
			width: 100%;
			height: auto;
			display: flex;
			flex-wrap: wrap;
		}
		
		.benefits_card {
			width: 50%;
			height: 70px;
			display: flex;
			align-items: center;
		}
		
		.benefit_item {
			display: flex;
			flex-direction: row;
		}
		
		.benefit_icon {
			margin-left: 30px;
			width: 44px;
			height: 44px;
		}
		
		.benefit_text {
			display: flex;
			flex-direction: column;
			margin-left: 10px;
		}
		
		.benefit_title {
			font-size: 14px;
			font-family: Alimama ShuHeiTi;
			font-weight: bold;
			color: #E6EFFE;
			opacity: 1;
		}
		
		.benefit_subTitle {
			font-size: 14px;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			opacity: 0.4;
		}
		
</style>